﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML
        xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
    <META content="IE=11.0000"
          http-equiv="X-UA-Compatible">

    <META http-equiv="Content-Type" content="text/html; charset=utf-8">
    <TITLE>发布新投票</TITLE>
    <LINK href="/css/style.css" rel="stylesheet" type="text/css">
    <SCRIPT src="/js/jquery.js" type="text/javascript"></SCRIPT>

    <SCRIPT type="text/javascript">

    </SCRIPT>

    <META name="GENERATOR" content="MSHTML 11.00.10586.420">
</HEAD>
<BODY>
<DIV class="wrap" id="header"><IMG src="/images/logo.gif"></DIV>
<DIV class="wrap" id="navbar">
    <DIV class="profile">您好，admin <SPAN class="return"><A
            href="/showList?updateKey=0">返回列表</A></SPAN>
        <SPAN class="addnew"><A href="/add.html">添加新投票</A></SPAN>
        <SPAN class="modify"><A href="http://localhost:8080/myVote/Subject-modify.action">维护</A></SPAN>
        <SPAN class="return"><A
                href="/logOut">注销</A></SPAN></DIV>
    <DIV class="search">
        <FORM action="Subject-search.action" method="post"><INPUT name="keywords" class="input-text" type="text"><INPUT
                name="submit" class="input-button" type="submit" value=""/>
        </FORM>
    </DIV>
</DIV>
<DIV class="box" id="voteManage">
    <H2>添加新投票 <span th:text="${addError}" style="color: red"></span></H2>
    <DIV class="content">
        <FORM onsubmit="return check();" action="/admin/addSubject" method="post" id="forms">
            <DL>
                <DT>投票内容：</DT>
                <DD><INPUT name="struts.token.name" type="hidden" value="token">
                    <INPUT name="token" type="hidden"
                           value="B1XPKLEQ7DQ6DNVWKBARPOY4HLYYXDE6">
                    <INPUT name="vsTitle" class="input-text" id="title" type="text">
                </DD>
                <DT>投票类型：</DT>
                <DD><INPUT name="vsType" type="radio" value="1" checked>单选
                    <INPUT name="vsType"
                           type="radio" value="2">多选
                </DD>
                <DT>投票选项：</DT>
                <DD id="voteoptions">
                    <P><INPUT name="options" class="input-text" type="text"></P>
                    <P><INPUT name="options" class="input-text" type="text"></P></DD>
                <DT></DT>
                <DD class="button"><INPUT type="image" src="/images/button_submit.gif">
                    <A onclick="AddOption()" href="javascript:void(0)">增加选项</A> <A
                            href="/showList">取消操作</A>
                </DD>
            </DL>
        </FORM>
    </DIV>
</DIV>
<DIV class="wrap" id="footer"> 北大青鸟 © 版权所有</DIV>
<script>
    function AddOption() {
        $("#voteoptions").append('<P><INPUT name="options" class="input-text" type="text"><a href="javascript:void(0)" class="deleteInput">删除</a> </P>')
    }
    $("#voteoptions").on("click",".deleteInput",function (){
        $(this).parent().empty()
    })
    function check() {
        const formVal = $("#forms").serializeArray()
        for (const formValElement of formVal) {
            if (formValElement.value == "") {
                alert("请将文本框内容填写完整")
                return false;
            }
        }
        return true;
    }
</script>
</BODY>
</HTML>
